package com.yc.myspringboot.aop.demo1;

import org.springframework.aop.aspectj.AspectJExpressionPointcut;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class InterceptorConfig {

	public static final String traceExecution = "execution(* com.yc.myspringboot.service.d1..*.*(..))";

	@Bean
	public DefaultPointcutAdvisor defaultPointcutAdvisor2() {
		TracingInterceptor interceptor = new TracingInterceptor();
		AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
		pointcut.setExpression(traceExecution);

		// 配置增强类advisor
		DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor();
		advisor.setPointcut(pointcut);
		advisor.setAdvice(interceptor);
		return advisor;
	}
}
